﻿<UserControl x:Class="XSemmel.Editor.XmlEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:avalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
             mc:Ignorable="d" 
             d:DesignHeight="120" d:DesignWidth="600">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="VisibilityOfBool" />
    </UserControl.Resources>
    <DockPanel>
        <StatusBar DockPanel.Dock="Bottom" >
            <!-- http://kentb.blogspot.com/2007/10/perfect-wpf-statusbar.html -->
            <StatusBarItem DockPanel.Dock="Left">
                <TextBlock x:Name="_lblModified" x:FieldModifier="private" Foreground="DarkRed" Width="70"
                       Visibility="{Binding ElementName=_textEditor, Path=IsModified, Converter={StaticResource VisibilityOfBool}}">
                        Modified
                </TextBlock>
            </StatusBarItem>
            <StatusBarItem DockPanel.Dock="Right">
                <StackPanel Orientation="Horizontal" MouseLeftButtonDown="UIElement_OnMouseLeftButtonUp">
                    <TextBlock Text="Length " />
                    <TextBlock x:Name="_lblSize" x:FieldModifier="private" Width="100" Text="{Binding ElementName=_textEditor, Path=Document.TextLength, StringFormat='{}{0:#,0} chars'}" />
                    <TextBlock x:Name="_lblCurrentLine" x:FieldModifier="private" Width="100">Ln</TextBlock>
                    <TextBlock x:Name="_lblCurrentColumn" x:FieldModifier="private" Width="100">Col</TextBlock>
                </StackPanel>
            </StatusBarItem>
            <StatusBarItem>
                <TextBlock x:Name="_lblXsdFile" x:FieldModifier="private" TextTrimming="CharacterEllipsis" Foreground="DarkGray" />
            </StatusBarItem>
        </StatusBar>

        <ContentPresenter 
            x:Name="_presenterFindString" 
            DockPanel.Dock="Bottom"
        />

        <avalonEdit:TextEditor x:Name="_textEditor" x:FieldModifier="private"
                               FontFamily="Consolas"
			                   SyntaxHighlighting="XML"
                               ShowLineNumbers="True" 
                               MouseHover="textEditor_MouseHover" 
                               MouseHoverStopped="textEditor_MouseHoverStopped"
                               MouseRightButtonDown="_textEditor_MouseRightButtonDown"
                               TextChanged="_textEditor_TextChanged"
            >
            <avalonEdit:TextEditor.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Paste" Command="Paste">
                        <MenuItem.Icon>
                            <Image Source="/Images/Paste_16x16.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                	<MenuItem Header="Cut" Command="Cut">
                        <MenuItem.Icon>
                            <Image Source="/Images/Cut.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                	<MenuItem Header="Copy" Command="Copy">
                        <MenuItem.Icon>
                            <Image Source="/Images/Copy.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="Collapse all" Click="mnuCollapseAll_Click">
                        <MenuItem.Icon>
                            <Image Source="/Images/CollapseAll_16x16.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Expand all" Click="mnuExpandAll_Click">
                        <MenuItem.Icon>
                            <Image Source="/Images/ExpandAll_16x16.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="Show selection as fragment" Click="mnuSelectionAsFragment_Click">
                        <MenuItem.Icon>
                          <Image Source="/Images/SelectionAsFragment.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </avalonEdit:TextEditor.ContextMenu>
        </avalonEdit:TextEditor>

    </DockPanel>

</UserControl>
